package com.bjc.scheduler.elasticjob.quickstart.demo;

import java.time.LocalDateTime;

/**
 * @program: elastic-job-quickstart
 * @description: Thread.sleep实现定时任务
 * @author: bjc
 * @create: 2021-08-15 19:09
 */
public class SimpleDemo1 {

    public static void main(String[] args) {
        //任务执行间隔时间
        final long timeInterval = 3000L;

        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                while (true) {
                    //TODO:something
                    System.out.printf("time：%s to do something", LocalDateTime.now());
                    System.out.println();
                    try {
                        Thread.sleep(timeInterval);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();
    }
}
